//
//  FindViewController.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/12.
//  Copyright © 2016年 Gcx. All rights reserved.
//

#import "FindViewController.h"
#import "GCTitleBtn.h"
#import "Feedback/FeedbackViewController.h"
#import "NamedViewController.h"
#import "SignViewController.h"

@interface FindViewController ()

{
    UIView *_topView;
    UIView *_middleView;
    UIView *_bottomView;
}

@property (nonatomic, strong) NSArray        *btnArr;
@property (nonatomic, strong) NSArray        *btntextArr;
@property (nonatomic, strong) NSArray        *dataArr;
@property (nonatomic, strong) NSArray        *dataTextArr;

@end

@implementation FindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavBarTitle:@"发现"];
    [self setNavBarLeftBtn:nil];
    
    [self buildUI];
    
}

- (void)buildUI{

    self.view.backgroundColor = BGC;
    
    self.btnArr = @[@"发现-意见反馈",@"发现-视频中心",@"发现-考试中心",@"发现-敬请期待"];
    self.btntextArr = @[@"意见反馈",@"视频中心",@"考试中心",@"敬请期待"];
    self.dataArr = @[@"发现-签到icon",@"发现-点名icon"];
    self.dataTextArr = @[@"课程签到",@"我要点名"];
    
    _topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, SIZEWIDTH, SIZEWIDTH/3)];
    _middleView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_topView.frame), SIZEWIDTH, 345*Bili)];
    _bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_middleView.frame), SIZEWIDTH, SIZEWIDTH/4)];
    
    _topView.backgroundColor    = [UIColor whiteColor];
    _middleView.backgroundColor = BGC;
    _bottomView.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:_topView];
    [self.view addSubview:_middleView];
    [self.view addSubview:_bottomView];
    
    [self creatTopView];   //上
    [self creatMiddleView];//中
    [self creatBottomView];//下
    
}

- (void)creatTopView{

    for (int i = 0; i < 2; i++) {
        
        GCTitleBtn *topBtn = [GCTitleBtn titleButton];
        
        topBtn.frame = CGRectMake((i%2)*SIZEWIDTH/2, 0, SIZEWIDTH/2, SIZEWIDTH/3);
        
        topBtn.tag = 1000+i;
        
        [topBtn setTitle:self.dataTextArr[i] forState:UIControlStateNormal];
        
        [topBtn setTitleColor:Color333333 forState:UIControlStateNormal];
        
        [topBtn setImage:[UIImage imageNamed:self.dataArr[i]] forState:UIControlStateNormal];
        
        topBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        topBtn.backgroundColor = [UIColor whiteColor];
        
        topBtn.titleLabel.font = NormalFont(40);
        
        [_topView addSubview:topBtn];
        
        [topBtn addTarget:self action:@selector(didClickSelectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        
    }
    
    for (int i = 1; i< 2; i++) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(i*SIZEWIDTH/2, ScaleSize(38), 0.5, SIZEWIDTH/3-ScaleSize(38)*2)];
        view.backgroundColor = colordbdbdb;
        [_topView addSubview:view];
    }

}

- (void)creatMiddleView{

    UIImageView *placeHolder = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SIZEWIDTH, 315*Bili)];
    
    placeHolder.image = [UIImage imageNamed:@"发现占位图"];
    
    [_middleView addSubview:placeHolder];
}

- (void)creatBottomView{

    for (int i = 0; i < self.btnArr.count; i++) {
        
        GCTitleBtn* _selectBtn = [GCTitleBtn titleButton];
        
        _selectBtn.frame = CGRectMake(i*SIZEWIDTH/4, 0, SIZEWIDTH/4, SIZEWIDTH/4);
        
        _selectBtn.tag = 100+i;
        
        if (_selectBtn.tag != 100) {
            
            [_selectBtn setTitleColor:Color999999 forState:UIControlStateNormal];
        }
        
        [_selectBtn setTitle:self.btntextArr[i] forState:UIControlStateNormal];
        
        [_selectBtn setImage:[UIImage imageNamed:self.btnArr[i]] forState:UIControlStateNormal];
        
        _selectBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        _selectBtn.backgroundColor = [UIColor whiteColor];
        
        _selectBtn.titleLabel.font = NormalFont(36);
        
        [_bottomView addSubview:_selectBtn];
        
        
        [_selectBtn addTarget:self action:@selector(didClickSelectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    for (int i = 1; i <= 3; i++) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(i*SIZEWIDTH/4, 0, 0.5, SIZEWIDTH/4)];
        view.backgroundColor = colordbdbdb;
        
        [_bottomView addSubview:view];
    }
    
    for (int i = 0; i < 2; i++) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, i*SIZEWIDTH/4, SIZEWIDTH, 0.5)];
        view.backgroundColor = colordbdbdb;
        
        [_bottomView addSubview:view];
    }

}

- (void)didClickSelectButtonAction:(UIButton *)sender{


    if (sender.tag == 1000) {
        
        SignViewController *sign = [[SignViewController alloc]init];
        
        sign.hidesBottomBarWhenPushed = YES;
        
        [self navigationCanDragBack:YES];
        
        [self.navigationController pushViewController:sign animated:YES];
    }
    
    if (sender.tag == 1001) {
        
        NamedViewController *named = [[NamedViewController alloc]init];
        
        named.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:named animated:YES];

    }
    
    if (sender.tag == 100) {
        
        FeedbackViewController *feedback = [[FeedbackViewController alloc]init];
        
        feedback.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:feedback animated:YES];
    }
}

@end
